#include <iostream>
using namespace std;

signed main()
{
    int n;
    cin>>n;
    int a=0,b=1;
    while(a+b<n){
        int t = a+b;
        a=b;
        b=t;
    }
    if(a+b-n<n-b)    cout<<a+b;
    else    cout<<b;
    return 0;
}
